#ifndef POINT_H
#define POINT_H

#include <iostream>

class point
{
    public:
        point(): x(0), y(0)
        {
        }

        point(double x, double y): x(x), y(y)
        {
        }

        bool operator==(const point &p) const
        {
            return (x == p.x) && (y == p.y);
        }

        bool operator!=(const point &p) const
        {
            return !(*this == p);
        }

        point &operator+=(const point &p)
        {
            x += p.x;
            y += p.y;

            return *this;
        }

        point &operator-=(const point &p)
        {
            x -= p.x;
            y -= p.y;

            return *this;
        }

        point operator+(const point &p) const
        {
            point tmp = *this;
            tmp += p;

            return tmp;
        }

        point operator-(const point &p) const
        {
            point tmp = *this;
            tmp -= p;

            return tmp;
        }

        double x, y;
};

class point_comparator
{
    public:
        bool operator()(const point &a, const point &b) const
        {
            return (a.x == b.x) ? (a.y < b.y) : (a.x < b.x);
        }
};

std::istream &operator>>(std::istream &is, point &p);

std::ostream &operator<<(std::ostream &os, const point &p);

#endif
